package com.dfbz.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

import java.io.IOException;
import java.util.Properties;

public class baseDao {
    public static JdbcTemplate jdbcTemplate;
    public  baseDao() {
        DruidDataSource druidDataSource = new DruidDataSource();
        Properties properties = new Properties();
        try {
            //加载配置文件
            properties.load(this.getClass().getClassLoader().getResourceAsStream("jdbc.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        druidDataSource.setUsername(properties.getProperty("jdbc.username"));
        druidDataSource.setPassword(properties.getProperty("jdbc.password"));
        druidDataSource.setUrl(properties.getProperty("jdbc.url"));
        druidDataSource.setDriverClassName(properties.getProperty("jdbc.driverClassName"));
        jdbcTemplate = new JdbcTemplate();
        jdbcTemplate.setDataSource(druidDataSource);
    }
}
